package com.qf.advice;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

/**
 * @ClassName ExceptionMyAdvice
 * @Description TODO
 * @Author 86181
 * @Date 2022/9/6 16:50
 * @Version 1.0
 **/
@ControllerAdvice //代表对所有controller注解进行增强 全局异常处理
public class ExceptionMyAdvice {
    @ExceptionHandler(RuntimeException.class)
    public ModelAndView indexPo(Exception ex){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("/error/error");
        modelAndView.addObject("message",ex.toString());
        return modelAndView;
    }
}
